package jrain.fw.business.utils;

import java.util.Map;

import jrain.fw.core.business.BusinessConst;
import jrain.fw.core.business.BusinessRequest;
import jrain.fw.core.utils.FwUtils;
import jrain.utils.lang.LangUtils;

public class BusinessUtils {

	public static long setId(BusinessRequest request) {
		return setId(request.getData());
	}

	public static long setId(Map<String, Object> data) {
		long id = FwUtils.getIdService().nextId();
		return setId(data, id);
	}

	public static long setId(Map<String, Object> data, long id) {
		data.put(BusinessConst.DATA_ID, id);
		return id;
	}

	public static long getCurrentUserId(BusinessRequest request) {
		return LangUtils.parseLong(request.getExtData(BusinessConst.EXT_USER_ID));
	}
}
